package com.um.jdy.common.charge.service.impl;

import com.um.jdy.common.device.dao.FeeEvTimeDao;
import com.um.jdy.common.device.entity.po.FeeEvTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.um.springboot.starter.orm.service.BaseEntityServiceImpl;
import com.um.jdy.common.charge.service.OrderEvTimeService;
import com.um.jdy.common.charge.dao.OrderEvTimeDao;
import com.um.jdy.common.charge.entity.po.OrderEvTime;

import java.util.List;

/**
 * 服务实现类：汽车桩-时段表
 */
@Service
@Transactional
@Slf4j
public class OrderEvTimeServiceImpl extends BaseEntityServiceImpl<OrderEvTimeDao,OrderEvTime>  implements OrderEvTimeService{


    @Autowired
    FeeEvTimeDao feeEvTimeDao;

    /**
     * 添加汽车桩价格表
     *
     * @param feeId
     * @param orderId
     */
    @Override
    public void addOrderEvTime(String feeId, String orderId) {
        List<FeeEvTime> times = feeEvTimeDao.getRows(new String[]{"device_fee_id"},new Object[]{feeId},
                new String[]{"start_time"},new String[]{"asc"});
        for(FeeEvTime price : times){
            OrderEvTime item = new OrderEvTime();
            item.setChargeOrderId(orderId);
            item.setComId(price.getComId());
            item.setType(price.getType());
            item.setStartTime(price.getStartTime());
            item.setEndTime(price.getEndTime());
            item.setCreateTime(price.getCreateTime());
            item.setLossScale(price.getLossScale());
            this.saveRow(item);
        }
    }
}
